package com.cskaoyan.controller.admin.configuration;

import com.cskaoyan.bean.MarketSystem;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.admin.configuration.AdminConfigMallVO;
import com.cskaoyan.bean.vo.admin.configuration.AdminConfigWXVO;
import com.cskaoyan.bean.vo.admin.promotion.AdminAdDeleteVO;
import com.cskaoyan.service.admin.configuration.AdminConfigService;
import com.cskaoyan.utils.HibernateValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/*
 * @Auther:王贲
 * @Date:2022/9/8
 * @Description:
 * @VERSON:1.8
 */
@RestController
@RequestMapping("admin/config")
public class AdminConfigController {

    @Autowired
    AdminConfigService adminConfigService;

    AdminConfigMallVO adminConfigMallVO;

    /**
     * @return com.cskaoyan.bean.common.BaseRespVo
     * @description : TODO 商场配置页面进入
     * @author wang'ben
     * @date 2022/9/8 20:06
     */
    @GetMapping("mall")
    public BaseRespVo mallConfig() {
        adminConfigMallVO = adminConfigService.selectConfigInfo();
        return BaseRespVo.ok(adminConfigMallVO);
    }


    /**
     * @description : TODO 商场配置页面更新
     * @return com.cskaoyan.bean.vo.admin.promotion.AdminAdDeleteVO
     * @author wang'ben
     * @date 2022/9/9 0:04
     */
    @PostMapping("mall")
    public AdminAdDeleteVO mallUpdate(@RequestBody Map<String, String> map, BindingResult bindingResult) {
        adminConfigService.updateInfo(map);
        return AdminAdDeleteVO.ok("成功");
    }



    /**
     * @description : TODO 运费配置页面进入
     * @return com.cskaoyan.bean.common.BaseRespVo
     * @author wang'ben
     * @date 2022/9/8 23:04
     */
    @GetMapping("express")
    public BaseRespVo expressConfig() throws IllegalAccessException {
        adminConfigMallVO = adminConfigService.selectExpressConfigInfo();
        return BaseRespVo.ok(adminConfigMallVO);
    }

    /**
     * @description : TODO 运费配置页面更新
     * @return com.cskaoyan.bean.vo.admin.promotion.AdminAdDeleteVO
     * @author wang'ben
     * @date 2022/9/9 0:05
     */
    @PostMapping("express")
    public AdminAdDeleteVO expressUpdate(@RequestBody Map<String, String> map) {
        adminConfigService.updateInfo(map);
        return AdminAdDeleteVO.ok("成功");
    }

    /**
     * @description : TODO 订单配置页面进入
     * @return com.cskaoyan.bean.common.BaseRespVo
     * @author wang'ben
     * @date 2022/9/8 23:04
     */
    @GetMapping("order")
    public BaseRespVo orderConfig() {
        adminConfigMallVO = adminConfigService.selectOrderConfigInfo();
        return BaseRespVo.ok(adminConfigMallVO);
    }

    /**
     * @description : TODO 订单配置页面更新
     * @return com.cskaoyan.bean.vo.admin.promotion.AdminAdDeleteVO
     * @author wang'ben
     * @date 2022/9/9 0:05
     */
    @PostMapping("order")
    public AdminAdDeleteVO orderUpdate(@RequestBody Map<String, String> map) {
        adminConfigService.updateInfo(map);
        return AdminAdDeleteVO.ok("成功");
    }
    /**
     * @description : TODO 微信小程序配置页面进入
     * @return com.cskaoyan.bean.common.BaseRespVo
     * @author wang'ben
     * @date 2022/9/8 23:04
     */
    @GetMapping("wx")
    public BaseRespVo wxConfig() {
        AdminConfigWXVO adminConfigWXVO = adminConfigService.selectWxConfigInfo();
        return BaseRespVo.ok(adminConfigWXVO);
    }


    /**
     * @description : TODO 微信配置页面更新
     * @return com.cskaoyan.bean.vo.admin.promotion.AdminAdDeleteVO
     * @author wang'ben
     * @date 2022/9/9 0:05
     */
    @PostMapping("wx")
    public AdminAdDeleteVO wxUpdate(@RequestBody Map<String, String> map) {
        adminConfigService.updateInfo(map);
        return AdminAdDeleteVO.ok("成功");
    }



}
